﻿package Interface
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class CGameStateUI_Result
	{
		private var m_refUIMovieClip :CMC_GameState_Result;
		
		public function CGameStateUI_Result(cMovieClip :MovieClip)
		{
			m_refUIMovieClip = cMovieClip as CMC_GameState_Result;
		}
		public function AddButtonClickHandler(fncNext :Function, fncGoToTitle :Function) :void
		{
			m_refUIMovieClip.btnNext.addEventListener(MouseEvent.CLICK, fncNext);
			m_refUIMovieClip.btnGoToTitle.addEventListener(MouseEvent.CLICK, fncGoToTitle);
		}
		public function RemoveButtonClickHandler(fncNext :Function, fncGoToTitle :Function) :void
		{
			m_refUIMovieClip.btnNext.removeEventListener(MouseEvent.CLICK, fncNext);
			m_refUIMovieClip.btnGoToTitle.removeEventListener(MouseEvent.CLICK, fncGoToTitle);
		}
		public function BuildUI() :void
		{
			if (CGameScoreManager.instance.bIsSuccess == true)
			{
				m_refUIMovieClip.textResult.text = "Clear!!";
				m_refUIMovieClip.btnNext.visible = true;
				m_refUIMovieClip.btnGoToTitle.visible = false;
			}
			else
			{
				m_refUIMovieClip.textResult.text = "Failure..";
				m_refUIMovieClip.btnNext.visible = false;
				m_refUIMovieClip.btnGoToTitle.visible = true;
			}
			m_refUIMovieClip.textMungLength.text = CGameScoreManager.instance.nMungLength.toString();
			m_refUIMovieClip.textEatedFoodCount.text = CGameScoreManager.instance.nEatedFoodCount.toString();
			m_refUIMovieClip.textGoldCount.text = CGameScoreManager.instance.nGold.toString();
			var nElapsedTime :Number = CGameScoreManager.instance.nElapsedTime;
			nElapsedTime = nElapsedTime*0.001;
			m_refUIMovieClip.textElapsedTime.text = uint(nElapsedTime).toString();
			m_refUIMovieClip.textElapsedTime.appendText(" 초");
			m_refUIMovieClip.textScore.text = CGameScoreManager.instance.nScore.toString();
			m_refUIMovieClip.textAddMung.text = CGameScoreManager.instance.GetAddPieceCount().toString();
		}

	}
}